FROM ubuntu:22.04

LABEL maintainer="Zheng Qijun <zhengqijun0121@qq.com>"

# amd64 / arm64
ARG PLATFORM=amd64
ARG AMD64_MIRROR=https://mirrors.tuna.tsinghua.edu.cn
ARG ARM64_MIRROR=https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports
ARG DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install -y --no-install-recommends ca-certificates && \
    if [ "$PLATFORM" == "amd64" ]; then \
        sed -i "s/http://security.ubuntu.com\|http://archive.ubuntu.com/${AMD64_MIRROR}/g" /etc/apt/sources.list \
    elif [ "$PLATFORM" == "arm64" ]; then \
        sed -i "s/http://security.ubuntu.com/ubuntu\|http://ports.ubuntu.com/${ARM64_MIRROR}/g" /etc/apt/sources.list \
    else \
        exit 1 \
    fi && \
    apt update && apt install -y --no-install-recommends tzdata python3 python3-pip vim neovim build-essential curl wget git tig \
        fontconfig openssh-server openssh-client libc-dev tmux ranger neofetch universal-ctags htop mosh ripgrep tree zip unzip \
        lzma shellcheck silversearcher-ag zathura xclip && \
    rm -rf /var/lib/apt/lists/* && \
    sed -i "s/#permitrootlogin.*/permitrootlogin yes/g" /etc/ssh/sshd_config && \
    echo 'root:111111' | chpasswd && \
    ssh-keygen -A && \
    cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
    git config --global user.name 'zhengqijun' && \
    git config --global user.email 'zhengqijun0121@qq.com' && \
    git clone -b lua https://gitee.com/zhengqijun/asd.git ~/.oh-my-dotfiles && \
    mv ~/.bashrc ~/.bashrcbak && \
    ln -s ~/.oh-my-dotfiles/bash/bashrc.bash ~/.bashrc && \
    ln -s ~/.oh-my-dotfiles/bash/bash_profile.bash ~/.bash_profile && \
    ln -s ~/.oh-my-dotfiles/npm/npmrc ~/.npmrc && \
    git clone https://gitee.com/zhengqijun/nvm ~/.nvm && \
    export NVM_NODEJS_ORG_MIRROR=http://npm.taobao.org/mirrors/node && \
    export NVM_IOJS_ORG_MIRROR=http://npm.taobao.org/mirrors/iojs && \
    source ~/.nvm/nvm.sh && nvm install v16.18.0 && nvm alias default v16.18.0 && \
    ln -s ~/.oh-my-dotfiles/tmux/tmux.conf ~/.tmux.conf && \
    ln -s ~/.oh-my-dotfiles/tmux/tmux.conf.local ~/.tmux.conf.local && \
    git clone https://gitee.com/zhengqijun/tpm ~/.tmux/plugins/tpm && \
    git clone https://gitee.com/zhengqijun/tmux-sensible ~/.tmux/plugins/tmux-sensible && \
    git clone https://gitee.com/zhengqijun/tmux-sidebar ~/.tmux/plugins/tmux-sidebar && \
    git clone https://gitee.com/zhengqijun/vim-tmux-navigator ~/.tmux/plugins/vim-tmux-navigator && \
    git clone https://gitee.com/zhengqijun/tmux-jump ~/.tmux/plugins/tmux-jump && \
    git clone https://gitee.com/zhengqijun/tmux-yank ~/.tmux/plugins/tmux-yank && \
    git clone https://gitee.com/zhengqijun/tmux-copycat ~/.tmux/plugins/tmux-copycat && \
    git clone https://gitee.com/zhengqijun/tmux-resurrect ~/.tmux/plugins/tmux-resurrect && \
    git clone https://gitee.com/zhengqijun/tmux-continuum ~/.tmux/plugins/tmux-continuum && \
    git clone https://gitee.com/zhengqijun/tmux-logging ~/.tmux/plugins/tmux-logging && \
    mkdir -p ~/.config ~/.vim ~/.local/share ~/.config/nvim && \
    ln -s ~/.oh-my-dotfiles/fonts ~/.local/share/fonts && \
    cd ~/.local/share/fonts && mkfontscale && mkfontdir && fc-cache -fv && \
    ln -s ~/.oh-my-dotfiles/ranger ~/.config/ranger && \
    ln -s ~/.oh-my-dotfiles/neofetch ~/.config/neofetch && \
    ln -s ~/.oh-my-dotfiles/nvim/init.lua ~/.config/nvim/init.lua && \
    ln -s ~/.oh-my-dotfiles/nvim/lua ~/.config/nvim/lua && \
    ln -s ~/.oh-my-dotfiles/vim/vimrc ~/.vimrc && \
    ln -s ~/.oh-my-dotfiles/vim/colors ~/.vim/colors && \
    ln -s ~/.oh-my-dotfiles/vim/files ~/.vim/files && \
    ln -s ~/.oh-my-dotfiles/pip ~/.pip && \
    pip3 install pynvim --no-cache-dir && \
    vim -c PlugInstall +qall && \
    nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'

ENV TERM xterm-256color
ENV SHELL /bin/bash
ENV HOME /root
ENV USER root
ENV USERNAME root

WORKDIR $HOME

# ENTRYPOINT ["/bin/bash"]

EXPOSE 22

CMD ["/usr/sbin/sshd", "-D"]

# EOF

